package StructuralPattern.Flyweight;

public class Client {
    public static void main(String[] args) {
        IgoChessman black1, black2, black3, white1, white2;
        IgoChessmanFactory igoChessmanFactory;

        // 获取享元工厂对象
        igoChessmanFactory = IgoChessmanFactory.getInstance();

        // 通过享元工厂获取3颗黑子
        black1 = igoChessmanFactory.getIgoChessman("b");
        black2 = igoChessmanFactory.getIgoChessman("b");
        black3 = igoChessmanFactory.getIgoChessman("b");
        System.out.println("判断黑子是否相同：" + (black1 == black2));

        // 通过享元工厂获取两颗白子
        white1 = igoChessmanFactory.getIgoChessman("w");
        white2 = igoChessmanFactory.getIgoChessman("w");
        System.out.println("判断白子是否相同：" + (white1 == white2));

        black1.display(new Coordinates(1,2));
        black2.display(new Coordinates(3,4));
        black3.display(new Coordinates(1,3));

        white1.display(new Coordinates(2,5));
        white2.display(new Coordinates(2,4));
    }
}
